package main

import "fmt"

func main() {

	var map01 = map[string]int{
		"id01": 01,
		"学号01": 2021,
	}

	var map02 = make(map[string]int)
	map02["id02"] = 01
	map02["学号02"] = 2020

	fmt.Printf("map01:%v\nmap02:%v\n", map01, map02)

	for key, val := range map01 {
		fmt.Printf("%s	%d\n", key, val)
	}

	for key, val := range map02 {
		fmt.Printf("%s	%d\n", key, val)
	}

	var map03 = make(map[string]int)
	var map04 = map[string]int{}

	fmt.Println(map03 != nil && map04 != nil)

	var nullMap map[string]int
	emptyMap := map[string]int{}

	fmt.Println(nullMap, len(nullMap) == 0)   //true
	fmt.Println(nullMap, nullMap == nil)      //true
	fmt.Println(emptyMap, len(emptyMap) == 0) //true
	fmt.Println(emptyMap, emptyMap == nil)    //false

	var map05 = map[string]int{
		"id05": 5,
		"学号05": 2022,
	}
	map05["QAQ"] = 8080
	for k, v := range map05 {
		fmt.Printf("新增后map05[%s] = %d\n", k, v)
	}

	map05["QAQ"] = 9090
	for k, v := range map05 {
		fmt.Printf("修改后map05[%s] = %d\n", k, v)
	}

	delete(map05, "QAQ")
	for k, v := range map05 {
		fmt.Printf("删除后map05[%s] = %d\n", k, v)
	}

	var val, result = map05["学号05"]

	if result {
		fmt.Printf("获取成功,val:%d,result:%v\n", val, result)
	} else {
		fmt.Println("获取失败")
	}

}
